package org.jeecg.common.util.wx;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum WxEventTypeEnum {

    SUBSCRIBE("subscribe","订阅"),
    UNSUBSCRIBE("unsubscribe","取消订阅"),
    SCAN("SCAN","已关注用户扫码"),
    LOCATION("LOCATION","上报地理位置"),
    CLICK("CLICK","自定义菜单事件"),
    VIEW("VIEW","点击菜单跳转链接事件");

    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private String desc;

    WxEventTypeEnum(String value, String desc){
        this.value = value;
        this.desc = desc;
    }

    public static WxEventTypeEnum getByValue(String value){
        List<WxEventTypeEnum> list = Arrays.stream(WxEventTypeEnum.values()).filter(o-> StringUtils.equals(o.getValue(),value)).limit(1).collect(Collectors.toList());
        if(list.size() > 0){
            return list.get(0);
        }
        return null;
    }
}
